package com.sgam.mf.domain.sec;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.springframework.format.annotation.DateTimeFormat;

import com.sgam.mf.domain.ref.RefBranch;
import com.sgam.mf.domain.ref.RefCityHall;
import com.sgam.mf.domain.ref.RefRegion;
import com.sgam.mf.domain.ref.RefRole;
import com.sgam.utils.CustomDateDeserializer;
import com.sgam.utils.CustomDateSerializer;

@Entity
@Table(name = "SEC_USER")
public class SecUser  {
	
	@Id
	@Column(name = "ID")
	@GeneratedValue
	private Integer id;	

	@Column(name = "IDNP")
    private String idnp;
	
	@Column(name = "LAST_NAME")
    private String lastName;

	@Column(name = "FIRST_NAME")
    private String firstName;

	@Column(name = "PATRONYMIC")
    private String patronymic;

	@Column(name = "SEX")
    private String sex;
	
	@JsonSerialize(using = CustomDateSerializer.class)
	@JsonDeserialize(using = CustomDateDeserializer.class)
	@DateTimeFormat(pattern="dd.MM.yyyy")
	@Column(name = "BIRTH_DATE")
    private Date birthDate;
	
	@Column(name = "USER_LOGIN")
    private String userLogin;
	
	@Column(name = "USER_PASSWORD")
    private String userPassword;
	
	@Column(name = "EMAL")
    private String emal;
	
	@Column(name = "CITY")
    private String city;
	
	@Column(name = "ZIP_CODE")
    private String zipCode;	
	
	@Column(name = "ADDRESS")
    private String address;
	
	@Column(name = "PHONE_HOME")
    private String phoneHome;
	
	@Column(name = "PHONE_MOB")
    private String phoneMob;
	
	@Column(name = "PHONE_SERV")
    private String phoneServ;
	
	@Column(name = "FAX")
    private String fax;	
	
	@Column(name = "SKYPE")
    private String skype;
	
	@Column(name = "ACTIVE")
    private Integer active = 1;
	
	@Column(name = "NOTES")
    private String notes;
	
	@Column(name = "UPDATED_BY_FK")
    private Integer updatedByFk;	
    
	@JsonSerialize(using = CustomDateSerializer.class)
	@JsonDeserialize(using = CustomDateDeserializer.class)
	@DateTimeFormat(pattern="dd.MM.yyyy")
	@Column(name = "UPDATED_DATE")
    private Date updatedDate;
	
	
	@ManyToOne
	@JoinColumn(name = "ref_branch_fk")		
    private RefBranch refBranch;
	
	@ManyToOne
	@JoinColumn(name = "ref_role_fk")		
    private RefRole 		refRole;
	
	
	@Transient
	private String fullName;

	@ManyToOne
	@JoinColumn(name = "ref_region_fk")		
    private RefRegion 		refRegion;
	
	@ManyToOne
	@JoinColumn(name = "ref_city_hall_fk")		
    private RefCityHall 		refCityHall;
	  
	  
	@Column(name = "primar_name")
	private String primarName;
	  
	@Column(name = "primar_tel")
	private String primarTel;  
	
	@Column(name = "primar_email")
	private String primarEmail;
	
	@Column(name = "stamp_number")
	private String stampNumber;
	 
	@Column(name = "stamp_coment")
	private String stampComent;	

	@Column(name = "limba_vorbirii")
	private Integer limbaVorbirii;
	
	@Column(name = "foto_id")
	private Integer fotoId = 0;
	
	@Column(name = "pano_id")
	private Integer panoId = 0;	
	
	@JsonIgnore
	@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER, orphanRemoval=true)
	@Fetch(value = FetchMode.SUBSELECT)
	@JoinColumn(name="SEC_USER_ID_FK")
	@OrderBy("visualOrder")
	private List<SecUserProcentDetail> 	secUserProcentDetail;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getIdnp() {
		return idnp;
	}

	public void setIdnp(String idnp) {
		this.idnp = idnp;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getPatronymic() {
		return patronymic;
	}

	public void setPatronymic(String patronymic) {
		this.patronymic = patronymic;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	public String getUserLogin() {
		return userLogin;
	}

	public void setUserLogin(String userLogin) {
		this.userLogin = userLogin;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public String getEmal() {
		return emal;
	}

	public void setEmal(String emal) {
		this.emal = emal;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPhoneHome() {
		return phoneHome;
	}

	public void setPhoneHome(String phoneHome) {
		this.phoneHome = phoneHome;
	}

	public String getPhoneMob() {
		return phoneMob;
	}

	public void setPhoneMob(String phoneMob) {
		this.phoneMob = phoneMob;
	}

	public String getPhoneServ() {
		return phoneServ;
	}

	public void setPhoneServ(String phoneServ) {
		this.phoneServ = phoneServ;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getSkype() {
		return skype;
	}

	public void setSkype(String skype) {
		this.skype = skype;
	}

	public Integer getActive() {
		return active;
	}

	public void setActive(Integer active) {
		this.active = active;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public Integer getUpdatedByFk() {
		return updatedByFk;
	}

	public void setUpdatedByFk(Integer updatedByFk) {
		this.updatedByFk = updatedByFk;
	}

	public Date getUpdatedDate() {
		return updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}

	public String getFullName() {
		return getLastName()+' '+getFirstName();
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public RefBranch getRefBranch() {
		return refBranch;
	}

	public void setRefBranch(RefBranch refBranch) {
		this.refBranch = refBranch;
	}

	public RefRole getRefRole() {
		return refRole;
	}

	public void setRefRole(RefRole refRole) {
		this.refRole = refRole;
	}

	public RefRegion getRefRegion() {
		return refRegion;
	}

	public void setRefRegion(RefRegion refRegion) {
		this.refRegion = refRegion;
	}

	public RefCityHall getRefCityHall() {
		return refCityHall;
	}

	public void setRefCityHall(RefCityHall refCityHall) {
		this.refCityHall = refCityHall;
	}

	public String getPrimarName() {
		return primarName;
	}

	public void setPrimarName(String primarName) {
		this.primarName = primarName;
	}

	public String getPrimarTel() {
		return primarTel;
	}

	public void setPrimarTel(String primarTel) {
		this.primarTel = primarTel;
	}

	public String getPrimarEmail() {
		return primarEmail;
	}

	public void setPrimarEmail(String primarEmail) {
		this.primarEmail = primarEmail;
	}

	public String getStampNumber() {
		return stampNumber;
	}

	public void setStampNumber(String stampNumber) {
		this.stampNumber = stampNumber;
	}

	public String getStampComent() {
		return stampComent;
	}

	public void setStampComent(String stampComent) {
		this.stampComent = stampComent;
	}

	public Integer getLimbaVorbirii() {
		return limbaVorbirii;
	}

	public void setLimbaVorbirii(Integer limbaVorbirii) {
		this.limbaVorbirii = limbaVorbirii;
	}

	public Integer getFotoId() {
		return fotoId;
	}

	public void setFotoId(Integer fotoId) {
		this.fotoId = fotoId;
	}

	public Integer getPanoId() {
		return panoId;
	}

	public void setPanoId(Integer panoId) {
		this.panoId = panoId;
	}

	public List<SecUserProcentDetail> getSecUserProcentDetail() {
		return secUserProcentDetail;
	}

	public void setSecUserProcentDetail(
			List<SecUserProcentDetail> secUserProcentDetail) {
		this.secUserProcentDetail = secUserProcentDetail;
	}


	
}
